package com.neu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.po.ResponseResult;
import com.neu.po.Supplier;
import com.neu.service.SupplierService;

@RestController
@RequestMapping("supplier")
public class SupplierController {

	@Autowired
	private SupplierService supplierService;
	
	@RequestMapping("getPage")
	public ResponseResult getPage(int pageNum,int pageSize,String keyword){
		
		ResponseResult result = new ResponseResult();
		
		result.setData(supplierService.getPage(pageNum, pageSize, keyword));
		
		return result;
	}
	
	@RequestMapping("insert")
	public ResponseResult insert (@RequestBody Supplier supplier) {
		ResponseResult result = new ResponseResult();
		
		result.setData(supplierService.insert(supplier));
		
		return result;
	}
	
	@RequestMapping("update")
	public ResponseResult update (@RequestBody Supplier supplier) {
		ResponseResult result = new ResponseResult();
		
		result.setData(supplierService.update(supplier));
		
		return result;
	}
	
	@RequestMapping("delete")
	public ResponseResult delete(int id) {
		ResponseResult result = new ResponseResult();
		
		result.setData(supplierService.delete(id));
		
		return result;
	}
}
